package org.yray.lock;

import java.util.concurrent.locks.LockSupport;

public class LockSupportTest {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(new ParkThread());

        Thread.sleep(100); //①
        System.out.println(Thread.currentThread().getName()+"开始唤醒阻塞线程");
        t.interrupt();
        t.start();
        System.out.println(Thread.currentThread().getName()+"结束唤醒");

    }
}

class ParkThread implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"开始阻塞");
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        LockSupport.park(this);
        System.out.println(Thread.currentThread().getName()+"AB："+Thread.currentThread().isInterrupted());
        Thread.interrupted();
        System.out.println(Thread.currentThread().getName()+"AF："+Thread.currentThread().isInterrupted());
        System.out.println(Thread.currentThread().getName()+"第一次结束阻塞");
        LockSupport.park(this);
        System.out.println("第二次结束阻塞");
    }
}
